package com.yzb.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandler implements InvocationHandler {

    private Object target;
    private String suffix;

    public MyInvocationHandler(Object target, String suffix) {
        this.target=target;
        this.suffix = suffix;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        args[0] = args[0] + suffix;                 // 可以对参数进行而外的处理，再传给目标方法
        return method.invoke(target, args);
    }
}
